package de.szut.ita13.rs.wave.spawn;

import java.util.Random;

import de.szut.ita13.rs.wave.controller.Controller;
import de.szut.ita13.rs.wave.entities.FastEnemy;
import de.szut.ita13.rs.wave.entity.Type;
import de.szut.ita13.rs.wave.hud.HUD;
import de.szut.ita13.rs.wave.main.Game;

public class Spawner {

	private Controller controller;
	private HUD hud;
	private Random r = new Random();
	
	private int scoreKeep = 0;
	private int stepper = 100;
	
	public Spawner(Controller controller, HUD hud) {
		this.controller = controller;
		this.hud = hud;
	}
	
	public void tick() {
		scoreKeep++;
		if(scoreKeep >= stepper) {
			scoreKeep = 0; 
			hud.setLevel(hud.getLevel() + 1);
			stepper *= 1.25;
			spawnEnemies();
		}
	}
	
	private void spawnEnemies() {
		controller.modificateEntity(new FastEnemy(r.nextInt(Game.WIDTH), r.nextInt(Game.HEIGHT), Type.FastEnemy, controller), Controller.Modification.ADD);
	}
	
}
